{include file="common/mini-header" title="权限节点"}
<div class="layui-body">
	<!-- 内容主体区域 -->

	<form class="layui-form" action="" style="max-width: 800px;width: 90%;">
		<div class="layui-form-item">
			<label class="layui-form-label">节点名称</label>
			<div class="layui-input-block">
				<input type="text" name="name" required lay-verify="required" placeholder="请输入菜单名称" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">节点链接</label>
			<div class="layui-input-block">
				<input type="text" name="rules" required lay-verify="required" placeholder="请输入url或者节点(/admin/控制器/方法)" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">所属菜单</label>
			<div class="layui-input-inline">
				<input type="text" readonly="readonly" value="{:$_GET['name']}" class="layui-input" />
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">所属类型</label>
			<div class="layui-input-block">
				<input type="radio" name="type" value="node" title="节点" checked>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<input type="hidden" name="pid" value="{:intval($_GET['pid'])}" />
				<button class="layui-btn" lay-submit lay-filter="addMenu">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>

</div>
<script>
	layui.use('form', function() {
		var form = layui.form;
		var $ = layui.jquery;
		var layer = layui.layer;

		//监听提交
		form.on('submit(addMenu)', function(data) {
			$.post('./addRule', data.field, function(rs) {
				if (rs.code==1) {
					layer.msg(rs.msg)
					setTimeout(function() { 
						parent.location.reload();
					}, 400)
				} else {
					layer.alert(rs.msg)
				}
			})
			return false;
		});
	});
</script>
{include file="common/footer"}
